package com.dlut.txy.designpattern.chainofresponsibility.approve2;

import com.dlut.txy.designpattern.chainofresponsibility.approve1.AskForLeaveApproveHandler;
import com.dlut.txy.designpattern.chainofresponsibility.approve1.entity.AskForLeaveRequest;

import java.util.ArrayList;
import java.util.List;

public class AskForLeaveApproveHandlerChain {
    private List<AskForLeaveApproveHandler> handlerList = new ArrayList<>();

    public AskForLeaveApproveHandlerChain addHandler(AskForLeaveApproveHandler handler) {
        handlerList.add(handler);
        return this;
    }

    public void handleRequest(AskForLeaveRequest request){
        for (AskForLeaveApproveHandler handler : handlerList) {
            handler.handleRequest(request);
        }
    }
}
